package com.milling.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.milling.common.annotation.Log;
import com.milling.common.core.controller.BaseController;
import com.milling.common.core.domain.AjaxResult;
import com.milling.common.enums.BusinessType;
import com.milling.business.domain.WmsTaskInfo;
import com.milling.business.service.IWmsTaskInfoService;
import com.milling.common.utils.poi.ExcelUtil;
import com.milling.common.core.page.TableDataInfo;

/**
 * 任务工单Controller
 *
 * @author X
 * @date 2025-02-27
 */
@RestController
@RequestMapping("/business/taskinfo")
public class WmsTaskInfoController extends BaseController
{
    @Autowired
    private IWmsTaskInfoService wmsTaskInfoService;

    /**
     * 查询任务工单列表
     */
    @PreAuthorize("@ss.hasPermi('business:taskinfo:list')")
    @GetMapping("/list")
    public TableDataInfo list(WmsTaskInfo wmsTaskInfo)
    {
        startPage();
        List<WmsTaskInfo> list = wmsTaskInfoService.selectWmsTaskInfoList(wmsTaskInfo);
        return getDataTable(list);
    }

    /**
     * 导出任务工单列表
     */
    @PreAuthorize("@ss.hasPermi('business:taskinfo:export')")
    @Log(title = "任务工单", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsTaskInfo wmsTaskInfo)
    {
        List<WmsTaskInfo> list = wmsTaskInfoService.selectWmsTaskInfoList(wmsTaskInfo);
        ExcelUtil<WmsTaskInfo> util = new ExcelUtil<WmsTaskInfo>(WmsTaskInfo.class);
        util.exportExcel(response, list, "任务工单数据");
    }

    /**
     * 获取任务工单详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:taskinfo:query')")
    @GetMapping(value = "/{taskId}")
    public AjaxResult getInfo(@PathVariable("taskId") String taskId)
    {
        return success(wmsTaskInfoService.selectWmsTaskInfoByTaskId(taskId));
    }

    /**
     * 新增任务工单
     */
    @PreAuthorize("@ss.hasPermi('business:taskinfo:add')")
    @Log(title = "任务工单", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsTaskInfo wmsTaskInfo)
    {
        return toAjax(wmsTaskInfoService.insertWmsTaskInfo(wmsTaskInfo));
    }

    /**
     * 修改任务工单
     */
    @PreAuthorize("@ss.hasPermi('business:taskinfo:edit')")
    @Log(title = "任务工单", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsTaskInfo wmsTaskInfo)
    {
        return toAjax(wmsTaskInfoService.updateWmsTaskInfo(wmsTaskInfo));
    }

    /**
     * 删除任务工单
     */
    @PreAuthorize("@ss.hasPermi('business:taskinfo:remove')")
    @Log(title = "任务工单", businessType = BusinessType.DELETE)
    @DeleteMapping("/{taskIds}")
    public AjaxResult remove(@PathVariable String[] taskIds)
    {
        return toAjax(wmsTaskInfoService.deleteWmsTaskInfoByTaskIds(taskIds));
    }
}
